from flask import Flask
from flask_mongoengine import MongoEngine

db = MongoEngine()

def create_app():
    app = Flask(__name__)



    # 此部分代码移移至 cinfig.py配置文件中;

    # app.config['MONGODB_SETTINGS'] = {
    #     'db': 'flask_news',
    #     'host': '127.0.0.1',
    #     'port': 27017
    # }

    #调用配置文件--获取mongodb数据库连接
    app.config.from_object('app.config')

    db.init_app(app)

    return app